package com.xrj4j.k_tally.view.viewmodel

import android.annotation.SuppressLint
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.lifecycle.ViewModel
import com.xrj4j.k_tally.db.IncomeList
import com.xrj4j.k_tally.db.OutcomeList
import com.xrj4j.k_tally.model.IconType
import com.xrj4j.k_tally.model.Kind

class EditViewModel : ViewModel() {
    val tabIndex = mutableIntStateOf(0)

    @SuppressLint("MutableCollectionMutableState")
    val typeList = mutableStateOf(if (tabIndex.intValue == Kind.OUTCOME.code) OutcomeList else IncomeList)


    val selectType = mutableStateOf(typeList.value[0])

    fun onClickTab(tabIndex: Int) {
        this.tabIndex.intValue = tabIndex
        if (tabIndex == Kind.OUTCOME.code) typeList.value = OutcomeList else IncomeList
    }

    fun onClickIcon(type: IconType) {
        selectType.value = type
    }
}